<template>
  <div>
    <div class="header">
      <h3>{{ news.title }}123123123</h3>
      <p>
        <span>发表时间：{{ news.add_time | dateFormat }}</span>
      </p>
    </div>

    <hr />

    <div class="content" v-html="news.content"></div>
    <comment-box :id="id"></comment-box>
  </div>
</template>

<script>
// 引入评论子组件
import comment from "../common/comment.vue";
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      id: this.$route.params.id,
      news: {}
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("api/getnew/" + this.id).then(result => {
        if (result.body.status === 0) {
          this.news = result.body.message[0];
        } else {
          Toast("获取新闻失败，请检查网络");
        }
      });
    }
  },
  components: {
    "comment-box": comment
  }
};
</script>

<style lang="scss">
.header {
  h3 {
    line-height: 30px;
    color: #22aaff;
    font-size: 22px;
    text-align: center;
  }
  p {
    display: flex;
    justify-content: flex-end;
  }
}

.content {
  p {
    text-indent: 2em;
    //   font-size: 1px;
    color: #333333;
  }
  img {
    width: 100%;
  }
}
</style>